﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Fish : MonoBehaviour {

	[HideInInspector]
	public float delayTime;
	private float preY;
	void Start () {
		
	}

	void Update () {
		if (GetComponent<Rigidbody2D> ().velocity.y < 0 && preY > 0) {
			GetComponent<GameAnimation> ().Play ();
		}
		preY = GetComponent<Rigidbody2D> ().velocity.y;
		if (transform.position.y < -10f) {
			Destroy (gameObject);
		}
	}

	public void fire(){
		preY = 15f;
		GetComponent<Rigidbody2D> ().velocity = new Vector3 (0, 15f, 0);
	}

	public void OnDisable(){
		
	}
}
